package A1_4;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

public class Order {
    private LocalDate createDate;
    private String status;
    private List<OrderDetail> details;
    private Payment payment;

    public static final String CREATE = "CREATE";
    public static final String PAID = "PAID";
    public static final String SHIPPING = "SHIPPING";
    public static final String DELIVERED = "DELIVERED";
    public static final String CANCEL = "CANCEL";

    public Order(LocalDate createDate, Payment payment) {
        this.createDate = createDate;
        this.status = CREATE;
        this.details = new ArrayList<>();
        this.payment = payment;
    }

    public void addDetail(OrderDetail detail) {
        details.add(detail);
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public LocalDate getCreateDate() {
        return createDate;
    }

    public String getStatus() {
        return status;
    }

    public List<OrderDetail> getDetails() {
        return details;
    }

    public double getTotalAmount() {
        double total = 0;
        for (OrderDetail detail : details) {
            total += detail.calculateSubTotal();
        }
        return total;
    }

    public double getTotalWeight() {
        double total = 0;
        for (OrderDetail detail : details) {
            total += detail.calculateWeight();
        }
        return total;
    }

    public Payment getPayment() {
        return payment;
    }
}
